package com.fable.ntzw_ga;

import com.fable.common.annotation.SpringContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;
import java.net.UnknownHostException;


@SpringBootApplication(scanBasePackages = "com.fable")
@EnableTransactionManagement
@EnableRabbit
@Slf4j
public class NtzwGaApplication {

    public static void main(String[] args) throws UnknownHostException {
        SpringContext springContext = new SpringContext();
        ConfigurableApplicationContext application = SpringApplication.run(NtzwGaApplication.class, args);
        springContext.setApplicationContext(application);
        Environment env = application.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "swagger: \thttp://{}:{}/api/swagger-ui.html\n\t" +
                        "Doc: \t\thttp://{}:{}/api/doc.html\n" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"));
    }

}
